package ynu.edu.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import ynu.edu.entity.User;

/**
 * 用户响应数据传输对象
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserResponse {
    private String userId;    // 用户ID
    private String userName;  // 用户名
    private Integer userSex;  // 用户性别
    private String userImg;   // 用户头像
    
    /**
     * 从User实体转换为UserResponse
     * @param user 用户实体
     * @return UserResponse对象
     */
    public static UserResponse fromEntity(User user) {
        if (user == null) {
            return null;
        }
        UserResponse response = new UserResponse();
        response.setUserId(user.getUserId());
        response.setUserName(user.getUserName());
        response.setUserSex(user.getUserSex());
        response.setUserImg(user.getUserImg());
        return response;
    }
} 